package com.huidao.service;

import java.util.List;

import com.huidao.dao.MenuDao;
import com.huidao.dao.MenuDaoImpl;
import com.huidao.entity.Menu;

public class MenuServiceImpl implements MenuService {
	int pageSize = 5;
	MenuDao dao = new MenuDaoImpl();

	public String addMenu(Menu Menu) {
		
		if(dao.addMenu(Menu)){
			return "";
		}else{
			return "添加失败";
		}
	}

	public String delMenu(String id) {
		
		if(dao.delMenu(Long.parseLong(id))){
			return "";
		}else{
			return "删除失败";
		}
	}

	public String updateMenu(Menu Menu) {
		
		if(dao.updateMenu(Menu)){
			return "";
		}else{
			return "修改失败";
		}
	}

	public List<Menu> getListPage(int currentPage, String namekey) {
		return dao.getListPage(currentPage, pageSize,namekey);
	}

	public int getTotalPage(String namekey) {
		
		int count = dao.getTotalCount(namekey);
		if(count%pageSize==0){
			return count/pageSize;
		}else{
			return count/pageSize+1;
		}
	}
	public List<Menu> getAllList(Long roleId){
		return dao.getAllList(roleId);
	}

}
